package com.example.tabbar.fragment

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.example.tabbar.adapter.ConcentrationAdapter
import com.example.tabbar.databinding.FragmentConcentrationBinding
import com.example.tabbar.room.bean.Concentration
import com.example.tabbar.utils.CustomLine


class ConcentrationFragment : Fragment() {
    private var binding: FragmentConcentrationBinding? = null
    private var recyclerView: RecyclerView? = null
    private var adapter: ConcentrationAdapter? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        arguments?.let {
        }
    }

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View {
        binding = FragmentConcentrationBinding.inflate(inflater, container, false)
        return binding!!.root
    }
    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        recyclerView = binding?.concentrationList
        adapter = ConcentrationAdapter()
        recyclerView?.adapter = adapter

        recyclerView?.layoutManager = LinearLayoutManager(requireContext())

        //分割线
        CustomLine(requireContext(),recyclerView!!)

        adapter?.setItems(listOf(
            Concentration(0.3f, "50000000"),
            Concentration(0.3f, "50000000"),
            Concentration(0.3f, "50000000"),
            Concentration(0.3f, "50000000"),
            Concentration(0.3f, "50000000"),
            Concentration(0.3f, "50000000")
        ))
    }

    companion object {

        @JvmStatic
        fun newInstance() =
            ConcentrationFragment().apply {
                arguments = Bundle().apply {

                }
            }
    }
}